const obj1 = { a: "11", b: { c: "22" } };
const obj2 = { a: "11", b: { c: "22" } };
const obj3 = { a: "11", b: [ {c: "22"}, {b : "33"}] };

function diff(obj1, obj2) {
    let o1 = obj1 instanceof Object;
    let o2 = obj2 instanceof Object;
    // 判断是不是对象
    if (!o1 || !o2) {
        return obj1 === obj2;
    }
    //Object.keys() 返回一个由对象的自身可枚举属性(key值)组成的数组,
    //例如：数组返回下表：let arr = ["a", "b", "c"];console.log(Object.keys(arr))->0,Array.prototype.unshift,2;
    if (Object.keys(obj1).length !== Object.keys(obj2).length) {
        return false;
    }
    for (let o in obj1) {
        let t1 = obj1[o] instanceof Object;
        let t2 = obj2[o] instanceof Object;
        // 两者都是对象 递归
        if (t1 && t2) {
            if (!diff(obj1[o], obj2[o])) {
                return false
            }
        }
        else if (obj1[o] !== obj2[o]) {
            return false;
        }
    }
    // 这也是递归一个递归出口
    return true;
}
console.log(diff(obj1, obj2));
console.log(diff(obj1, obj3));
